home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 3 / CD ACTUAL 3.iso / linux / system / srouted-.000 / srouted- / srouted-0.1pl1 / table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-17  |  4.2 KB  |  131 lines

  1. /* table.h -- (srouted) routing table management */
  2.  
  3. /*
  4.  *    $Id: table.h,v 1.1 1995/01/27 04:44:50 buhr Exp $
  5.  */
  6.  
  7. #ifndef INC_TABLE_H
  8. #define INC_TABLE_H
  9.  
  10. #ifndef DEFEXTS
  11. #define EXTERN extern
  12. #else
  13. #define EXTERN
  14. #endif DEFEXTS
  15.  
  16. #include <sys/time.h>
  17. #include <sys/socket.h>
  18. #include <net/if.h>
  19.  
  20. /*
  21.  * Structure to store interface information
  22.  */
  23.  
  24. struct tb_iface {
  25.     char        tbif_dev[IFNAMSIZ];  /* device name */
  26.     struct sockaddr    tbif_myaddr;    /* our address on interface */
  27.     struct sockaddr    tbif_netmask;    /* subnet mask address */
  28.     struct sockaddr    tbif_broadaddr;    /* broadcast address */
  29.     struct sockaddr    tbif_dstaddr;    /* dest address for p-p links */
  30.     short        tbif_metric;    /* total cost of interface */
  31.     short        tbif_flags;
  32. };
  33.  
  34. #define TBIFF_UP    0x0001        /* interface is up */
  35. #define TBIFF_BROADCAST 0x0002        /* broadcast address valid */
  36. #define TBIFF_LOOPBACK    0x0008        /* interface is loopback */
  37. #define TBIFF_POINTOPOINT 0x0010    /* destination address valid */
  38.  
  39. #define TBIFF_USED    0x0020        /* this entry is used */
  40.  
  41. #define TB_IFACE_SIZE    16        /* interface table entries */
  42.  
  43. #define TBM_INFINITY    16
  44.  
  45. EXTERN struct tb_iface tb_iface[TB_IFACE_SIZE];
  46.  
  47.  
  48. /*
  49.  * Structure for a (srouted) routing table entry
  50.  */
  51.  
  52. struct tb_route {
  53.     struct sockaddr    tbrt_dst;    /* address of destination */
  54.     struct sockaddr    tbrt_mask;    /* mask for this network */
  55.     struct sockaddr    tbrt_gateway;    /* address of gateway */
  56.     int        tbrt_iface;    /* interface of route (-1 if none) */
  57.     int        tbrt_supernet;    /* supernet route (-1 if none) */
  58.     short        tbrt_metric;    /* total cost to destination */
  59.     short        tbrt_flags;
  60.     time_t        tbrt_timer;    /* time of timeout/garb coll */
  61. };
  62.  
  63. #define TBRTF_USED    0x0001        /* this route entry is in use */
  64. #define TBRTF_CHANGED    0x0002        /* route change flag */
  65. #define TBRTF_DIRECT    0x0004        /* directly connected interface */
  66. #define TBRTF_DELETED    0x0008        /* entry has been deleted */
  67. #define TBRTF_KEEP    0x0010        /* keep kernel's route on delete/kill */
  68. #define TBRTF_KILLED    0x0020        /* entry has been killed */
  69. #define TBRTF_HOST    0x0040        /* route is a host route */
  70. #define TBRTF_TENTATIVE    0x0080        /* replace ASAP, ignoring metric */
  71. #define TBRTF_SUBNET    0x0100        /* subnetted route */
  72. #define TBRTF_SUPERNET    0x0200        /* net record for subnetted net */
  73. #define TBRTF_TIMEOUT    0x0400        /* tbrt_timer contains timeout */
  74. #define TBRTF_GARBCOLL    0x0800        /* tbrt_timer contains garbcoll */
  75. #define TBRTF_TIMERON    (TBRTF_TIMEOUT|TBRTF_GARBCOLL)
  76. #define TBRTF_DEFAULT    0x1000        /* this is the default route */
  77.  
  78. #define TB_ROUTE_SIZE    128        /* route table entries */
  79.  
  80. EXTERN struct tb_route tb_route[TB_ROUTE_SIZE];
  81.  
  82.  
  83. /*
  84.  *    Structure for analysis of a network address
  85.  */
  86.  
  87. struct tb_address {
  88.     struct sockaddr tba_addr;    /* original address */
  89.     struct sockaddr tba_hostsa;    /* portless address, as sockaddr */
  90.     struct sockaddr tba_subnetsa;    /* subnet, as sockaddr */
  91.     struct sockaddr tba_netsa;    /* net, as sockaddr */
  92.     struct sockaddr tba_supmasksa;    /* supernet mask, as sockaddr */
  93.     short        tba_af;        /* address family */
  94.     long        tba_network;    /* network number */
  95.     long        tba_host;    /* host number */
  96.     unsigned short    tba_port;    /* port number */
  97.     long        tba_subnet;    /* subnet number */
  98.     long        tba_netmask;    /* subnet mask */
  99.     int        tba_iface;    /* interface assoc with address */
  100.     short tba_flags;
  101. };
  102.  
  103. #define TBAF_CLASSA    0x0001        /* network address class */
  104. #define TBAF_CLASSB    0x0002
  105. #define TBAF_CLASSC    0x0004
  106. #define TBAF_CLASSABC    (TBAF_CLASSA|TBAF_CLASSB|TBAF_CLASSC)
  107. #define TBAF_HOST    0x0008        /* is a single host */
  108. #define    TBAF_SUBNET    0x0010        /* subnetted network */
  109. #define TBAF_DEFAULT    0x0020        /* address is the default route */
  110. #define TBAF_BROADCAST    0x0040        /* was a broadcast address */
  111. #define TBAF_VALID    0x0080        /* address was valid */
  112. #define TBAF_LOOPBACK    0x0100        /* address is loopback */
  113.  
  114. int tb_newiface( void );
  115. int tb_newroute( void );
  116. unsigned long int tb_satoip( struct sockaddr *sa );
  117. void tb_iptosa( unsigned long int a, struct sockaddr *sa );
  118. int tb_findroute( struct sockaddr *dst );
  119. int tb_samehost( struct sockaddr *a1, struct sockaddr *a2 );
  120. void tb_initroute( void );
  121. short tb_rtmetric( struct sockaddr dst );
  122. void tb_chkaddr( struct tb_address *a );
  123. void tb_addroute( int route, struct tb_address *dest,
  124.          struct tb_address *gw, short cost );
  125. void tb_delroute( int route, struct tb_address *dest );
  126. void tb_killroute( int route );
  127.  
  128. #undef EXTERN
  129.  
  130. #endif INC_TABLE_H
  131.